<div>
    <h3>-------------------------------------Unit Test Instruction-----------------------------------</h3>
</div>
 

<div>
    <h4>Create Unit Test</h4>
    <ul>
        <li>Create a folder under any folder, name: <b>kbtest</b></li>
        <li>Create one or more regular js file to store your unit test</li>
        <li>Create one function for every unit test, that function will be called during test</li>
    </ul>

</div>

<div>
    <h4>Add reference in your JS file</h4>
    <ul>
        <li>Create a file in your folder, name: <b>ref.txt</b></li>
        <li>Insert one reference url one line in the file</li>
        <li>The reference js will be added when running the test</li>
    </ul>
</div>

<div>
    <h4>Use of requireJs</h4>
    <ul>
        <li>
            You should place your unit test as functions inside the second argument of Require or Define function. 
            Exmaple: 
            <pre>
                require(["util"], function(u) { function YourUnitTest(){expect(a).to.be(b);}   function SecondUnitTest(){expect(a).to.be(c);} });
</pre>
        </li> 
    </ul>
</div>

<div>
    <h4>Assertation syntax</h4>
    <p>It uses the expect.js assertation, see: <a href="https://github.com/Automattic/expect.js">https://github.com/Automattic/expect.js</a></p>

    <p>
         Example: 
    </p> 
    <ul>
        <li>expect(window.r).to.be(undefined);</li>
        <li>expect({ a: 'b' }).to.eql({ a: 'b' })</li>
        <li>expect(5).to.be.a('number');</li>
        <li>expect([]).to.be.an('array');</li>
        <li>expect(window).not.to.be.an(Image); </li> 
    </ul>
</div>

<div>
    <h4>kMock syntax</h4>
    <p>
        Example:mock new Object
    </p>
    <ul>
        <li>var helper={}</li>
        <li>KMock(helper).callFake("test",function(){return 1})</li>
        <li>expect(helper.test()).to.eql(1);</li>
    </ul>

    <p>
        Example:mock exist Object
    </p>
    <ul>
        <li>var helper=new Helper()</li>
        <li>KMock(helper).callFake("getname",function(){return "name"})</li>
        <li>expect(helper.getname()).to.eql("name");</li>
    </ul>

    <p>
        Example:flush mock 
    </p>
    <ul>
        <li>var helper={getname:function(){return "helperName"}}</li>
        <li>KMock(helper).callFake("getname",function(){return "name"})</li>
        <li>expect(helper.getname()).to.eql("name");</li>
        <li>KMock(helper).flush()</li>
        <li>expect(helper.getname()).to.eql("helperName");</li>
    </ul>
</div>